﻿using System;
using System.Collections.Generic;
using System.Text;

namespace _010_011_012操作符详解_11_类型转换
{
    internal class Program
    {
      
        static void Main(string[] args)
        {
            //显式类型转换
            //string str1 = Console.ReadLine();
            //string str2= Console.ReadLine();
            //int x = Convert.ToInt32(str1);
            //int y = Convert.ToInt32(str2);
            //Console.WriteLine(x+y);


            Console.WriteLine(ushort.MaxValue);
            uint x = 65535;

            //精度截取 高的16位会被截取
            ushort y =(ushort)x;

            //隐式类型转换
            //1.不丢失精度的类型转换  2.子类向父类的转换
            //int a = 10;
            //long b = a;
            //Console.WriteLine(b);

            Teacher t =new Teacher();
            Human h = t;
            h.Eat();
            h.Think();
            //h.Teach();
            //获取不到 Teach  方法 ,因为C#规定子类向父类转换只能有原有的东西

            //var result = t is Teacher;
            //Console.WriteLine(result.GetType().FullName); //System.Boolean
            //Console.WriteLine(result);      //True
            //Console.WriteLine(t is Object);
            object o = new Teacher();
            if( o is Teacher)
            {
                Teacher teacher = (Teacher)o;
                teacher.Teach();
            }

            object obj =new Teacher();
            Teacher tea = o as Teacher;
            if(tea != null)
            {
                tea.Teach();
            }
        }

       class Animal
        {
            public void Eat()
            {
                Console.WriteLine("Eating ...");
            }
        }
        //继承anima类
        class Human:Animal
        {
            public void Think()
            {
                Console.WriteLine("Who I am ");
            }
        }

        class Teacher : Human
        {
            public void Teach()
            {
                Console.WriteLine("I teach programmming");
            }
        }

    }
}
